import 'package:erp/UI/CodeResources/Localization.dart';
import 'package:erp/UI/Components/HeroLogoSliverAppbar.dart';
import 'package:flutter/material.dart';

class CustomizedScaffold extends StatelessWidget {

  double expandedHeight;
  Widget appbarContent;
  String title;
  SliverChildListDelegate contentDelegate;
  Widget floatingActionButton;
  bool pinned;
  bool useSearchBar;
  Widget drawer;
  Widget endDrawer;
  Color backgroundColor;
  void Function(String text) searchHandler = (String text){};

  CustomizedScaffold({
    this.expandedHeight = 250.0,
    this.appbarContent, this.title,
    this.contentDelegate,
    this.floatingActionButton,
    this.pinned = true,
    this.useSearchBar = false,
    this.drawer,
    this.endDrawer,
    this.searchHandler,
    this.backgroundColor
  });

  @override
  Widget build(BuildContext context) {
    var currentLocale = AppLocalizations.of(context);
    return Directionality(
        textDirection: currentLocale.textDirection,
        child: Scaffold(
          floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
          floatingActionButton: floatingActionButton,
          drawer: drawer,
          endDrawer: endDrawer,
          body: Container(
            color: backgroundColor,
            child: CustomScrollView(
              slivers: <Widget>[
                HeroLogoSliverAppbar(
                  title: title,
                  pinned: pinned,
                  appbarContent: appbarContent,
                  expandedHeight: expandedHeight,
                  useSearchBar: useSearchBar,
                  searchHandler: searchHandler,
                ),
                SliverList(delegate: contentDelegate)
              ],
            ),
          )
        )
    );
  }
}

